#include "mainclass.h"
#include "threadclass.h"
#include <QDebug>
#include <QtConcurrent/QtConcurrentRun>

MainClass::MainClass(QObject *parent) : QObject{parent} {
    connect(this, &MainClass::start, this, &MainClass::onStart);
}

void MainClass::onStart() {
    QFuture<void> future = QtConcurrent::run([&]() {
        ThreadClass thread;
        connect(this, &MainClass::stop, &thread, &ThreadClass::stop);
        emit thread.start();
    });
    synchronizer.addFuture(future);
    synchronizer.waitForFinished();
    synchronizer.clearFutures();

    qDebug() << "MainClass::onStart() end";
}
